<?php
class NewsItemObjModel extends Model {

	public function getNewsItem($id) {
		$query = sprintf("
			SELECT
				`news`.`id`, UNIX_TIMESTAMP(`news`.`date_add`) as `date_add`, `news`.`title`, `news`.`text`, `news`.`visible`, `news`.`sticky`
			FROM
				`news`
			WHERE
				`news`.`id` = %d;
		", $id);
		return $this->_sqlInstance->query($query);
	}

	public function save(NewsItem $newsItem) {
		$query = sprintf("
			INSERT INTO
				`news`(`title`, `text`, `visible`, `sticky`)
			VALUES
				('%s', '%s', %d, %d);
		", $newsItem->getTitle(), $newsItem->getText(), $newsItem->getVisible(), $newsItem->getStick());
		return $this->_sqlInstance->query($query);
	}

	public function update(NewsItem $newsItem) {
		
	}
}